clear
cd "C:\Users\JGW99\Dropbox\Forest\Data"

use CEE_Data\OwnerLevelDataSept282023_VerNov82024_R1, replace

*********************************************************
*Additional variable creation and sample trimming
******************************************************

*participation stats
tab group if year==2020

*Creating owner-level engagement group indicators
gen iint=(group>0)
gen iengaged=(group>1)
gen ipart=(group==3)

*average enrolled acreage
mean forestHaEngaged if ipart==1

*group percentages
mean iint iengaged ipart if year==2020

*Total number of one-parcel owners among enrolled owners
count if parcels==1 & ipart==1 & year==2019

*total number of parcels among enrolled owners
total parcels if ipart==1 & year==2019

*Participation rate among largests forestlandowners

xtile qrt=forestHa if year==2019, n(4)
total forestHa if year==2019, over(qrt)
matrix tf_qrt=e(_N)

total forestHa if year==2019 & group==3, over(qrt)
matrix tf_qrt_e=e(_N)

mata
tf_qrt=st_matrix("tf_qrt")
tf_qrt_e=st_matrix("tf_qrt_e")
part=tf_qrt_e :/ tf_qrt
part
end

sum forestHa if year==2019, detail
scalar fa_q75=r(p75)
count if forestHa >fa_q75 & year==2019
scalar nq75=r(N)
count if forestHa >fa_q75 & group==3 & year==2019

di "Owner enrollment rate among large forest owners = " r(N)/nq75 /*1.6 percent*/


